import { HttpException,HttpStatus, Injectable } from '@nestjs/common';

@Injectable()  //代表这个类可以被注入到controller当中
export class TestService {
  getTest(): string {
    return 'test!????';
  }

    getData( params): string {
      console.log(params)
      if(!params.id||!Number.isInteger(Number(params.id))){
        throw new HttpException("必须包含id参数，且参数必须是整数",HttpStatus.BAD_REQUEST)
      }
      return 'getData'+params.id+params.subId
    }

    getAllData(): string {
      return 'AllData'
    }

    addData( body, query): string {
      console.log(body,query)
      return 'AddData'+JSON.stringify(body)+'id'+query.id
    }
    updateData(): string {
      return 'UpdateData'
    }
    deleteData(): string {
      return 'DeleteData'
    }
}
